package com.it.validation;

import com.it.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;


//自定义注解
public class StateValidation implements ConstraintValidator<State,String> {


//    s是要校验的数据
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        //校验规则
        if(s == null){
            return false;
        }
        if(s.equals("已发布") || s.equals("草稿")){
            return true;
        }
        return false;
    }
}
